package com.sxdz.web

import com.sxdz.api.webService.CalculatorDelegate
import com.sxdz.api.webService.CalculatorService
import com.sxdz.api.webService.CustomerVo
import com.sxdz.api.webService.ResultVo
import com.sxdz.api.webService.UserCardCtmCardRltVo
import com.sxdz.api.webService.UserInfoVo
import com.sxdz.api.webService.UserPdtRltVo
import com.sxdz.constant.MessageConstant
import com.sxdz.controller.handler.CalculatorHandler
import com.sxdz.models.common.JsonResult
import groovy.transform.CompileStatic
import groovy.transform.TypeChecked
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.RestController

import javax.xml.namespace.QName


/**
 * Created by Administrator on 2016/8/12.
 */
@CompileStatic
@TypeChecked
@RestController
@RequestMapping("test")
public class maintest {

    @RequestMapping(value = "test", method = RequestMethod.GET)
    @ResponseBody
    getWebs(){
        try{
        CalculatorDelegate calculatorDelegate= CalculatorHandler.getCalculatorPort();
            //获取客户编号
            List<UserCardCtmCardRltVo> list=calculatorDelegate.getUserCardCtmCardAll("8035199001019691")
        List<CustomerVo> list2=calculatorDelegate.getCustomerAll((list.get(0) as UserCardCtmCardRltVo).ctmCard,"8035199001019691")
        println("----------------------------------------------------"+list2.size())
            println("----------------------------------------------------"+(list2.get(0) as CustomerVo).customerName+"|"+(list2.get(0) as CustomerVo).noId+"|"+(list2.get(0) as CustomerVo).address+"|"+(list2.get(0) as CustomerVo).getMPhone())
            return new JsonResult<Object>(MessageConstant.SUCCESS,list2.get(0) as CustomerVo)
        }catch (Exception e){
            e.printStackTrace();
            return new JsonResult<Object>(MessageConstant.FAILURE,"")
        }

    }

    @RequestMapping(value = "getUserCardCtmCardAll", method = RequestMethod.GET)
    @ResponseBody
    getUserCardCtmCardAll(){
        try{
            CalculatorDelegate calculatorDelegate= CalculatorHandler.getCalculatorPort();
            List<UserCardCtmCardRltVo> list2=calculatorDelegate.getUserCardCtmCardAll("8035199001019691")
            println("----------------------------------------------------"+list2.size())
        }catch (Exception e){
            e.printStackTrace();
        }
        return new JsonResult<Object>(MessageConstant.SUCCESS,null)
    }

    @RequestMapping(value = "getUserPdtRltInfo", method = RequestMethod.GET)
    @ResponseBody
    getUserPdtRltInfo(){
        try{
            CalculatorDelegate calculatorDelegate= CalculatorHandler.getCalculatorPort();
            List<UserCardCtmCardRltVo> list=calculatorDelegate.getUserCardCtmCardAll("8035199001019691")
            List<UserPdtRltVo> list2=calculatorDelegate.getUserPdtRltInfo((list.get(0) as UserCardCtmCardRltVo).ctmCard)
            println("----------------------------------------------------"+list2.size())
            return new JsonResult<Object>(MessageConstant.SUCCESS,list2.get(0) as UserPdtRltVo)
        }catch (Exception e){
            e.printStackTrace();
            return new JsonResult<Object>(MessageConstant.FAILURE,null)
        }

    }

    @RequestMapping(value = "getUserInfoAll", method = RequestMethod.GET)
    @ResponseBody
    getUserInfoAll(){
        try{
            CalculatorDelegate calculatorDelegate= CalculatorHandler.getCalculatorPort();
            List<UserCardCtmCardRltVo> list=calculatorDelegate.getUserCardCtmCardAll("8035199001019691")
            List<UserInfoVo> list2=calculatorDelegate.getUserInfoAll((list.get(0) as UserCardCtmCardRltVo).ctmCard)
            println("----------------------------------------------------"+list2.size())
            return new JsonResult<Object>(MessageConstant.SUCCESS,list2.get(0) as UserInfoVo)
        }catch (Exception e){
            e.printStackTrace();
            return new JsonResult<Object>(MessageConstant.FAILURE,null)
        }

    }


    @RequestMapping(value = "wx_charge_pdt_judge", method = RequestMethod.GET)
    @ResponseBody
    wx_charge_pdt_judge(){
        try{
            CalculatorDelegate calculatorDelegate= CalculatorHandler.getCalculatorPort();
            List<ResultVo> list=calculatorDelegate.wxChargePdtJudge("123456","8035199001019691","120","1","12","1","10004")
            println("----------------------------------------------------"+list.size())
            return new JsonResult<Object>(MessageConstant.SUCCESS,list.get(0) as ResultVo)
        }catch (Exception e){
            e.printStackTrace();
            return new JsonResult<Object>(MessageConstant.FAILURE,null)
        }

    }

    @RequestMapping(value = "wx_charge_pdt", method = RequestMethod.GET)
    @ResponseBody
    wx_charge_pdt(){
        try{
            CalculatorDelegate calculatorDelegate= CalculatorHandler.getCalculatorPort();
            List<ResultVo> list=calculatorDelegate.wxChargePdt("12345678","8035199001019691","120","1","12","1","10004")
            println("----------------------------------------------------"+list.size())
            return new JsonResult<Object>(MessageConstant.SUCCESS,list.get(0) as ResultVo)
        }catch (Exception e){
            e.printStackTrace();
            return new JsonResult<Object>(MessageConstant.FAILURE,null)
        }

    }


}
